Page({


  data: {
    order_nav: ["进行中", "待支付", "已结束", "已关注"],
    nav_checked: 0,
  },

  onLoad: function (options) {
    this.orderData(this.data.nav_checked)
  },
  // nav 点击事件
  ClickChecked(e) {
    var _this = this
    var index = e.currentTarget.dataset.index
    _this.setData({
      nav_checked: index
    })
    this.orderData(index)
  },
  // 订单数据请求
  orderData(e) {
    var _this = this
    wx.showLoading({
      title: "正在疯狂加载中...."
    })
    getApp().request({
      url: getApp().api.auction.my_auction,
      method: "GET",
      data: {
        status: e
      },
      success(res) {
        _this.setData({
          list: res.data.list
        })
        wx.hideLoading()
      },
      fail(res) {}
    })
  },
  clickCancel(e) {
    var auction_id = e.currentTarget.dataset.auction_id,
      bidid = e.currentTarget.dataset.bidid
    getApp().request({
      url: getApp().api.auction.cancel,
      method: "POST",
      data: {
        auction_id: auction_id,
        bidid: bidid
      },
      success(res) {
        wx.showToast({
          title: res.msg,
          icon: "none"
        })
        this.orderData(this.data.nav_checked)
      },
      fail(res) {
        wx.showToast({
          title: res.msg,
          icon: "none"
        })
        this.orderData(this.data.nav_checked)
      }
    })

  },
  ClickPay(e) {
    wx.navigateTo({
      url: '/auction/order/order?id=' + e.currentTarget.dataset.bidid,
    })
  }
})